#!/usr/bin/env python
# -*- coding: utf-8 -*-
# File  :pantum_dingtalk.py
# Time  :2025/5/20 17:16
# Email :fortunatedong@163.com
# Author:by Adonli
import requests
import toml
from streamlit import success
import os
from config import ROOT_DIR
configs_toml_path = os.path.join(ROOT_DIR,'utils/monitoring_early_warning', 'configs.toml')
class MessagePush():
    def __init__(self,message):
        self._cfg = toml.load(configs_toml_path)
        self._robot_url = self._cfg['DINGROBOT']['robot_url']
        self.message = message

    def pantum_alert_message(self):
        waiting_completion_num = len(self.message)
        # waiting_completion = self.message
        success_robot_body_at = {
            "msgtype": "markdown",
            "markdown": {
                "title": "奔图400来新单了！",
                "text": f"### 奔图400来新单了！\n\n"
                        f"- #### 新单数量：<font color=\"#E4080A\">{waiting_completion_num}</font>\n\n"
                        f"- #### 新单单号：<font color=\"#E4080A\">{self.message}</font>\n\n"
                        f"@15913121337",
            },
            "at": {
                "isAtAll": "false",
                "atMobiles": ["xxxxxxxxxxxx"]
            }
        }
        # print(success_robot_body_at)
        res = requests.post(url=self._robot_url, json=success_robot_body_at)